package cn.gson.fengboot.controller;

import cn.gson.fengboot.model.pojos.Zinvoice;
import cn.gson.fengboot.model.service.ZinvoiceService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/vue")
public class ZinvoiceController {
    @Autowired
    ZinvoiceService fpservice;

    //发票查询方法
    @RequestMapping("/list_kaipiao")
    @ResponseBody
    public Map<String,Object> kaipiao(Integer page, Integer size,String search,String search2){
        Page<Object> obj = PageHelper.startPage(page, size);
        fpservice.kaipiao(search,search2);

        Map<String,Object> map = new HashMap<>();
        map.put("total",obj.getTotal());
        map.put("rows",obj.getResult());
        return map;
    }

    //订单详情发票查询
    @RequestMapping("/list_kaipiaodd")
    @ResponseBody
    public List<Zinvoice> kaipiaodd(String search){

        return fpservice.kaipiaodd(search);
    }

    //退货单详情发票查询
    @RequestMapping("/list_kaipiaothd")
    @ResponseBody
    public List<Zinvoice> kaipiaothd(String search){

        return fpservice.kaipiaothd(search);
    }

    //回款详情发票查询
    @RequestMapping("/list_kaipiaohk")
    @ResponseBody
    public List<Zinvoice> kaipiaohk(String search){

        return fpservice.kaipiaohk(search);
    }


    //新增
    @RequestMapping("/add_fapiao")
    @ResponseBody
    public void addfapiao(@RequestBody Zinvoice fp){
        fpservice.addfapiao(fp);
    }
}
